using UnityEngine;
using System.Collections;

public class AIWalk : MonoBehaviour 
{

	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	
	public float walkSpeed = 2.0f;
    public float wallLeft = 0.0f;
    public float wallRight = 5.0f;

    float walkingDirection = 1.0f;
    Vector3 walkAmount;

    // Update is called once per frame
    void Update () 
	{

        walkAmount.x = walkingDirection * walkSpeed * Time.deltaTime;
		walkAmount.x = Mathf.Clamp(walkAmount.x, -101, 100);
		
        if (walkingDirection > 0.0f && transform.position.x >= wallRight)
            walkingDirection = -1.0f;
        else if (walkingDirection < 0.0f && transform.position.x <= wallLeft)
            walkingDirection = 1.0f;

        transform.Translate(walkAmount);
		
    }
}